#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int k;
    cin>>k;
    string s; 
    for(int i=0;i<k;i++){
        int cnt=0;
        cin>>s;
        for(int j=0;j<s.length();j++){
            int t=stoi(s.substr(0,j+1));
            if(t%(j+1)==0){
                cnt++;
                continue;
            } else break;
        }
        if(cnt==s.length()) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}
